package com.flxz.user.controller;

import com.flxz.common.core.controller.BaseController;
import com.flxz.common.core.domain.AjaxResult;
import com.flxz.user.service.IUserRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 用户记录Controller
 * 提供收入和支出记录的查询功能
 */
@RestController
@RequestMapping("/user/records")
public class UserRecordController extends BaseController {

    @Autowired
    private IUserRecordService userRecordService;

    /**
     * 获取用户记录列表（收入+支出）
     */
    @GetMapping
    public AjaxResult getRecords(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String type,
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate) {
        Long userId = getUserId();
        Map<String, Object> result = userRecordService.getRecords(userId, page, pageSize, type, startDate, endDate);
        return success(result);
    }
}
